//
//  GCSettingViewController.m
//  GoldChampion
//
//  Created by Mac on 2018/4/11.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "GCNotifacationViewController.h"
#import "GCCommentNotifactionViewController.h"
@interface GCNotifacationViewController ()
@property(nonatomic, strong) NSArray                     *dataSouce;
@property(nonatomic, strong) UISwitch                     *fansSwitch;
@property(nonatomic, strong) UISwitch                     *liveSwitch;
@property(nonatomic, strong) UISwitch                     *funSwitch;
@end

@implementation GCNotifacationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"通知设置";
    [self configDataSouce];
    
    // Do any additional setup after loading the view.
}

- (void)configDataSouce{

    
    
    STTableEasyModel * fansModel =  [[STTableEasyModel alloc] initWithTextString:@"新粉丝"
                                                                          detailString:@""];
    self.fansSwitch = [self deflutSwitch];
    fansModel.accessoryView = self.fansSwitch;
    
    
    STTableEasyModel * liveModel =  [[STTableEasyModel alloc] initWithTextString:@"直播"
                                                                       detailString:@""];
    self.liveSwitch = [self deflutSwitch];
    liveModel.accessoryView = self.liveSwitch;
    
    
    STTableEasyModel * funModel =  [[STTableEasyModel alloc] initWithTextString:@"推荐我可能感兴趣的作品"
                                                                    detailString:@""];
    self.funSwitch = [self deflutSwitch];
    funModel.accessoryView = self.funSwitch;
    
    
    NSArray * section0 =  @[
                            [[STTableEasyModel alloc] initWithTextString:@"评论"
                                                               detailString:@"" accessoryType:UITableViewCellAccessoryDisclosureIndicator],
                            fansModel];
    
    NSArray * section1 =  @[
                            liveModel
                            ];
    NSArray * section2 =  @[
                            funModel
                            ];
    self.dataSouce = @[
                       section0,
                       section1,
                       section2
                       ];
    [self.tableView reloadData];
    
}
- (UISwitch*)deflutSwitch{
    UISwitch * switchView = [UISwitch new];
    switchView.onTintColor = UIColorFromRGBA(0x3ECD74);
    [switchView addTarget:self action:@selector(switchViewChangedValue:) forControlEvents:UIControlEventValueChanged];
    return switchView;
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.dataSouce.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return [self.dataSouce[section] count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 55;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 24;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    STTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    [cell setSt_tableEasyModel:model];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    STTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    if ([model.textString containsString:@"评论"]) {
        [self.navigationController pushViewController:[GCCommentNotifactionViewController new] animated:YES];
    }
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

#pragma mark --Action Method
- (void)switchViewChangedValue:(UISwitch*)sender{
    
}

@end

